#include "util.h"
#include <fstream>
#include <new>

using namespace std;

int readVariableLength(ifstream &file) throw ()
{
    int value = 0;
    char reading;

    do {
        file.get(reading);
        value <<= 7;
        value |= (reading & 0x7F);
    } while (reading & 0x80);

    return value;
}

void extendAllocation(char* &data, int length, int &allocLength) throw (bad_alloc)
{
    if (length > allocLength) {
        delete[] data;
        data = new char[length];
        allocLength = length;
    }
}
